var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, a) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var a in t)
              Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
          })(t, a);
      };
      return function (t, a) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        e(t, a),
          (t.prototype =
            null === a
              ? Object.create(a)
              : ((i.prototype = a.prototype), new i()));
      };
    })(),
  AXTaoYuanPageView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_taoyuan_back.on(Laya.Event.CLICK, t, t.onTaoYuanBackAction),
        (t.list_select_xin.vScrollBarSkin = ""),
        (t.list_select_xin.selectEnable = !0),
        t.list_select_xin.on(Laya.Event.CLICK, t, t.onSelectXinDidClick),
        (t.list_select_xin.renderHandler = new Handler(t, t.updateItemXin)),
        (t.list_select_lan.vScrollBarSkin = ""),
        (t.list_select_lan.selectEnable = !0),
        t.list_select_lan.on(Laya.Event.CLICK, t, t.onSelectLanDidClick),
        (t.list_select_lan.renderHandler = new Handler(t, t.updateItemLan)),
        t.btn_yongjietongxin.on(
          Laya.Event.CLICK,
          t,
          t.onYongjietongxinDidClick
        ),
        t.btn_yijiejinlan.on(Laya.Event.CLICK, t, t.onYijiejinlanDidClick),
        t.btn_lihun.on(Laya.Event.CLICK, t, t.onLihunDidClick),
        WebSocketService.addListener({
          caller: t,
          code: 1333,
          method: t.onLoadData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1371,
          method: t.onCommonLoad,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 708,
          method: t.onCommonLoad,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1367,
          method: t.onCommonLoad,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5282,
          method: t.onCommonLoad,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 13424,
          method: t.onCommonLoad,
        }),
        Laya.stage.on("AXTaoYuanPageView", t, t.eventHandler),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showTaoYuanPageView = function () {
        return (
          null == this.taoyuanPageView && (this.taoyuanPageView = new t()),
          (this.taoyuanPageView.data = null),
          (this.taoyuanPageView.list_select_xin.dataSource = []),
          (this.taoyuanPageView.list_select_lan.dataSource = []),
          WebSocketService.send({ c: 1333 }),
          this.taoyuanPageView
        );
      }),
      (t.prototype.onLoadData = function (e) {
        if (0 == e.code) {
          var t = e.data;
          if (((this.data = e.data), 0 == t.marryState)) {
            for (var a = [], i = t.marryList, n = 0; n < i.length; n++) {
              s = {
                label_name: { text: (r = i[n]).userName },
                roleId: r.roleId,
              };
              a.push(s);
            }
            this.list_select_xin.dataSource = a;
          } else this.list_select_xin.dataSource = [];
          if (
            (3 == t.marryState
              ? ((this.label_alert.visible = !0),
                (this.btn_lihun.visible = !0),
                (this.label_alert.text = "你的配偶请求与你协议离婚"),
                (this.btn_lihun.label = "同意"))
              : 2 == t.marryState
              ? ((this.label_alert.visible = !0),
                (this.btn_lihun.visible = !0),
                (this.label_alert.text =
                  "已向【" + t.marryUserName + "】发起永结同心邀请"),
                (this.btn_lihun.label = "撤销"))
              : 4 == t.marryState
              ? ((this.label_alert.visible = !0),
                (this.btn_lihun.visible = !0),
                (this.label_alert.text = "你已向配偶发起协议离婚申请"),
                (this.btn_lihun.label = "撤销"))
              : ((this.label_alert.visible = !1),
                (this.btn_lihun.visible = !1)),
            0 == t.mateState)
          ) {
            for (var o = [], l = t.mateList, n = 0; n < l.length; n++) {
              var r = l[n],
                s = {
                  label_name: { text: r.userName },
                  label_site: { text: r.siteName },
                  mateId: r.mateId,
                  siteId: r.siteId,
                };
              o.push(s);
            }
            this.list_select_lan.dataSource = o;
          } else this.list_select_lan.dataSource = [];
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onSelectXinDidClick = function (e) {
        e.target.name;
        var t =
          "你确定与好友【" +
          e.currentTarget.selectedItem.label_name.text +
          "】永结同心吗？";
        AXTaoYuanSureDialog.showDialog({
          title: "永结同心",
          msg: t,
          from: "AXTaoYuanPageView",
          code: "xin",
        });
      }),
      (t.prototype.onSelectLanDidClick = function (e) {
        e.target.name;
        var t =
          "你确定与好友【" +
          e.currentTarget.selectedItem.label_name.text +
          "】义结金兰吗？";
        AXTaoYuanSureDialog.showDialog({
          title: "义结金兰",
          msg: t,
          from: "AXTaoYuanPageView",
          code: "lan",
        });
      }),
      (t.prototype.updateItemXin = function (e, t) {
        e.dataSource,
          e.getChildByName("label_name"),
          e.getChildByName("btn_sel");
      }),
      (t.prototype.updateItemLan = function (e, t) {
        e.dataSource,
          e.getChildByName("label_name"),
          e.getChildByName("label_site"),
          e.getChildByName("btn_sel");
      }),
      (t.prototype.onYongjietongxinDidClick = function () {
        var e = this.data;
        if (null != e) {
          if (
            (1 == e.marryState &&
              AXTaoYuanLihunDialog.showDialog({ name: e.userName }),
            0 == e.marryState && AXTaoYuanListDialog.showDialog(1),
            2 == e.marryState)
          ) {
            var t =
              "您已向好友【" +
              e.marryUserName +
              "】发起永结同心邀请，请等待对方同意";
            ToastView.toastView(t);
          }
        } else ToastView.toastView("数据加载中请稍等");
      }),
      (t.prototype.onYijiejinlanDidClick = function () {
        var e = this.data;
        e.mateState < 0 && ToastView.toastView("数据加载中请稍等"),
          0 == e.mateState && AXTaoYuanNameDialog.showDialog(),
          1 == e.mateState && AXTaoYuanListDialog.showDialog(2, e.mateId);
      }),
      (t.prototype.onLihunDidClick = function () {
        if (3 == this.data.marryState) {
          AXTaoYuanSureDialog.showDialog({
            title: "永结同心",
            msg: "你确定要和伴侣协议离婚吗？",
            from: "AXTaoYuanPageView",
            code: "lihun",
            cancelCode: "noLihun",
            cancelText: "拒绝",
          });
        }
        2 == this.data.marryState && WebSocketService.send({ c: 1367 }),
          4 == this.data.marryState && WebSocketService.send({ c: 5282 });
      }),
      (t.prototype.eventHandler = function (e) {
        if (e) {
          if ("xin" == e) {
            t = this.list_select_xin.selectedItem;
            WebSocketService.send({ c: 1371, d: { roleId: t.roleId } });
          }
          if (
            ("lihun" == e && WebSocketService.send({ c: 708, d: { type: 9 } }),
            "noLihun" == e && WebSocketService.send({ c: 708, d: { type: 1 } }),
            "lan" == e)
          ) {
            var t = this.list_select_lan.selectedItem;
            WebSocketService.send({ c: 13424, d: { mateId: t.mateId } });
          }
        }
      }),
      (t.prototype.onCommonLoad = function (e) {
        if ((ToastView.toastView(e.msg), 0 == e.code)) {
          if (13424 == e.code) {
            var t = this.list_select_lan.selectedItem;
            AXTaoYuanListDialog.showDialog(2, t.mateId);
          }
          WebSocketService.send({ c: 1333 });
        }
      }),
      (t.prototype.onTaoYuanBackAction = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.SquareController.AXTaoYuanPageViewUI);
